package vn.bang.xiangqi.components;

import java.util.Collection;

import vn.bang.xiangqi.infrastructure.Position;
import vn.bang.xiangqi.infrastructure.Vector;
import vn.bang.xiangqi.utility.BoardUtil;

public class King extends AbstractBaseNode {
	public King() {
		super();
	}

	public King(Position originalPosition) {
		super(originalPosition);
	}

	private static Vector[] KING_VECTORS = { new Vector(0, -1),
			new Vector(0, +1), new Vector(-1, 0), new Vector(+1, 0), };

	@Override
	protected boolean notPrevented(Vector vector, Collection<INode> ours,
			Collection<INode> enemies) {
		return true;
	}

	@Override
	protected Vector retrieveVectorMovingTo(Position destinationPosition) {
		if (null == destinationPosition
				|| !BoardUtil.IsInBoard(destinationPosition)) {
			return null;
		}

		return retrieveVectorValidInOurBarrack(destinationPosition,
				KING_VECTORS);
	}
}